const express = require('express');
const router = express.Router();

// 模拟首页数据
const mockHomeData = {
  // 首页Tab数据
  tab: ['首页', '服装鞋帽', '交通工具', '家电', '家居家具', '珠宝配饰', '美妆个护', '运动户外', '母婴用品', '玩具乐器', '手机', '数码', '电脑办公'],

  // 轮播图数据
  swiper: [
    {
      swiper: '/static/images/home/swiper/swiper-1.png',
      background: '/static/images/home/swiper/swiper-background-1.png',
    },
    {
      swiper: '/static/images/home/swiper/swiper-2.png',
      background: '/static/images/home/swiper/swiper-background-2.png',
    },
    {
      swiper: '/static/images/home/swiper/swiper-3.png',
      background: '/static/images/home/swiper/swiper-background-3.png',
    }
  ],

  // 导航图标数据
  nav: [
    {
      id: 1,
      name: '手机',
      color: 'orange',
      badge: '必看',
      img: '/static/images/home/grid-icon/1.png',
    },
    {
      id: 2,
      name: '平板',
      color: '',
      badge: '',
      img: '/static/images/home/grid-icon/2.png',
    },
    {
      id: 3,
      name: '电脑',
      color: 'orange',
      badge: '热卖',
      img: '/static/images/home/grid-icon/3.png',
    },
    {
      id: 4,
      name: '数码',
      color: '',
      badge: '',
      img: '/static/images/home/grid-icon/4.png',
    },
    {
      id: 5,
      name: '家电',
      color: '',
      badge: '',
      img: '/static/images/home/grid-icon/5.png',
    },
    {
      id: 6,
      name: '新人红包',
      color: '',
      badge: '',
      img: '/static/images/home/grid-icon/6.png',
    },
    {
      id: 7,
      name: '手机直播',
      color: '',
      badge: '',
      img: '/static/images/home/grid-icon/7.png',
    },
    {
      id: 8,
      name: '自营图书',
      color: 'red',
      badge: '必看',
      img: '/static/images/home/grid-icon/8.png',
    },
    {
      id: 9,
      name: '游戏',
      color: '',
      badge: '',
      img: '/static/images/home/grid-icon/9.png',
    },
    {
      id: 10,
      name: '二手车',
      color: '',
      badge: '',
      img: '/static/images/home/grid-icon/10.png',
    },
    {
      id: 11,
      name: '文玩玉翠',
      color: '',
      badge: '',
      img: '/static/images/home/grid-icon/11.png',
    },
    {
      id: 12,
      name: '免费领',
      color: '',
      badge: '',
      img: '/static/images/home/grid-icon/12.png',
    },
    {
      id: 13,
      name: '借钱',
      color: '',
      badge: '',
      img: '/static/images/home/grid-icon/13.png',
    },
    {
      id: 14,
      name: '拍卖',
      color: '',
      badge: '',
      img: '/static/images/home/grid-icon/14.png',
    },
    {
      id: 15,
      name: '分期商城',
      color: '',
      badge: '',
      img: '/static/images/home/grid-icon/15.png',
    }
  ],

  // 直播数据
  live: [
    {
      id: 1,
      name: '图文鉴别',
      text: '验过的更放心',
      img: '/static/images/home/sundry/3.png',
    },
    {
      id: 2,
      name: '免费鉴别',
      text: '专家24h在线',
      img: '/static/images/home/sundry/4.png',
    },
    {
      id: 3,
      name: '连麦鉴别',
      text: '2114人正在看',
      img: '/static/images/home/sundry/5.png',
    }
  ],

  // 赚钱数据
  earn: [
    {
      text: 'xxx赚了560元',
      img: '/static/images/avatar/1.jpg',
    },
    {
      text: 'xxx赚了3元',
      img: '/static/images/avatar/2.jpg',
    },
    {
      text: 'xx赚了20元',
      img: '/static/images/avatar/3.jpg',
    },
    {
      text: 'xxx赚了98元',
      img: '/static/images/avatar/4.jpg',
    },
    {
      text: 'xx赚了0.1元',
      img: '/static/images/avatar/5.jpg',
    }
  ],

  // 快速销售数据
  sellQuickly: [
    {
      id: 1,
      title: '手机保卖',
      text: '99%卖出',
      img: '/static/images/home/sundry/6.png',
    },
    {
      id: 2,
      title: '拍卖报名',
      text: '24小时高价卖',
      img: '/static/images/home/sundry/7.png',
    },
    {
      id: 3,
      title: '高价回收',
      text: '高价回收',
      img: '/static/images/home/sundry/8.png',
    }
  ],

  // 活动数据
  activity: [
    {
      id: 1,
      title: '转转社区',
      text: '发现有趣',
      img: '/static/images/home/sundry/11.png',
    },
    {
      id: 2,
      title: '手机直播',
      text: '直降400元',
      img: '/static/images/home/sundry/10.png',
    },
    {
      id: 3,
      title: '新人专享',
      text: '',
      img: '/static/images/home/sundry/12.png',
    },
    {
      id: 4,
      title: '爆款大促',
      text: '',
      img: '/static/images/home/sundry/13.png',
    },
    {
      id: 5,
      title: '5元3本',
      text: '',
      img: '/static/images/home/sundry/14.png',
    },
    {
      id: 6,
      title: '全新拍卖',
      text: '',
      img: '/static/images/home/sundry/15.png',
    }
  ],

  // 商品Tab数据
  goodsTab: [
    {
      title: '看推荐',
      tag: '',
    },
    {
      title: '逛附近',
      tag: '',
    },
    {
      title: '直播',
      tag: '秒杀中',
    },
    {
      title: '实惠好货',
      tag: '',
    },
    {
      title: '短视频',
      tag: '',
    }
  ],

  // 推荐数据
  recommend: {
    type: 'recommend',
    list: [
      {
        title: '商品标题',
        img: '/static/images/home/goods/16.png',
      },
      {
        title: '商品标题',
        img: '/static/images/home/goods/15.png',
      },
      {
        title: '商品标题',
        img: '/static/images/home/goods/14.png',
      },
      {
        title: '商品标题',
        img: '/static/images/home/goods/13.png',
      }
    ]
  },

  // 直播数据
  liveData: [
    {
      tag: '630万人',
      tag_title: [],
      tag_time: '',
      tag_red: '抢100元红包',
      tag_red_bg: '',
      title: '莫山山的直播',
      name: '大河国莫山山',
      appreciate: '7.5万',
      avatar: '/static/images/avatar/1.jpg',
      cover_img: '/static/images/home/live/1.jpg',
    },
    {
      tag: '',
      tag_title: [],
      tag_time: '',
      tag_red: '',
      tag_red_bg: '',
      title: '',
      name: '',
      appreciate: '',
      avatar: '',
      cover_img: '/static/images/home/live/2.jpg',
    },
    {
      tag: '630万人',
      tag_title: [],
      tag_time: '',
      tag_red: '',
      tag_red_bg: '特惠秒杀 00:07:05',
      title: 'XXXX的直播',
      name: 'XXXX',
      appreciate: '100万+',
      avatar: '/static/images/avatar/2.jpg',
      cover_img: '/static/images/home/live/3.jpg',
    },
    {
      tag: '',
      tag_title: ['鉴别中', '演戏'],
      tag_time: '',
      tag_red: '',
      tag_red_bg: '',
      title: '刘诗诗的直播',
      name: '刘诗诗',
      appreciate: '98.8万',
      avatar: '/static/images/avatar/3.jpg',
      cover_img: '/static/images/home/live/4.jpg',
    },
    {
      tag: '',
      tag_title: [],
      tag_time: '预约中 - 02/28 22:00',
      tag_red: '',
      tag_red_bg: '',
      title: '某某某的直播',
      name: '某某某',
      appreciate: '2345',
      avatar: '/static/images/avatar/4.jpg',
      cover_img: '/static/images/home/live/5.jpg',
    },
    {
      tag: '',
      tag_title: [],
      tag_time: '鉴别预约中 - 唱歌',
      tag_red: '',
      tag_red_bg: '',
      title: '某某的直播',
      name: '某某-某某',
      appreciate: '9812',
      avatar: '/static/images/avatar/5.jpg',
      cover_img: '/static/images/home/live/6.jpg',
    }
  ],

  // 视频数据
  videoData: [
    {
      title: '某某某的视频',
      name: '某某某',
      appreciate: '499',
      avatar: '/static/images/avatar/1.jpg',
      cover_img: '/static/images/home/video/1.jpg',
    },
    {
      title: '某某某的视频',
      name: '某某某',
      appreciate: '499',
      avatar: '/static/images/avatar/2.jpg',
      cover_img: '/static/images/home/video/2.gif',
    },
    {
      title: '某某某的视频',
      name: '某某某',
      appreciate: '499',
      avatar: '/static/images/avatar/3.jpg',
      cover_img: '/static/images/home/video/3.gif',
    },
    {
      title: '某某某的视频',
      name: '某某某',
      appreciate: '499',
      avatar: '/static/images/avatar/4.jpg',
      cover_img: '/static/images/home/video/4.gif',
    },
    {
      title: '某某某的视频',
      name: '某某某',
      appreciate: '499',
      avatar: '/static/images/avatar/5.jpg',
      cover_img: '/static/images/home/video/5.gif',
    }
  ],

  // 网格分类数据
  gridSortData: [
    {
      id: 1,
      name: '手机',
      img: '/static/images/home/grid-icon/16.png',
    },
    {
      id: 2,
      name: '平板',
      img: '/static/images/home/grid-icon/17.png',
    },
    {
      id: 3,
      name: '电脑',
      img: '/static/images/home/grid-icon/18.png',
    },
    {
      id: 4,
      name: '数码',
      img: '/static/images/home/grid-icon/19.png',
    },
    {
      id: 5,
      name: '家电',
      img: '/static/images/home/grid-icon/20.png',
    },
    {
      id: 6,
      name: '新人红包',
      img: '/static/images/home/grid-icon/21.png',
    },
    {
      id: 7,
      name: '手机直播',
      img: '/static/images/home/grid-icon/22.png',
    },
    {
      id: 8,
      name: '自营图书',
      img: '/static/images/home/grid-icon/23.png',
    },
    {
      id: 9,
      name: '游戏',
      img: '/static/images/home/grid-icon/24.png',
    }
  ]
};

// 获取首页Tab数据
router.post('/tab', (req, res) => {
  try {
    res.json({
      code: 200,
      message: '成功',
      data: mockHomeData.tab
    });
  } catch (error) {
    res.status(500).json({
      code: 500,
      message: '服务器错误',
      data: null
    });
  }
});

// 获取轮播图数据
router.post('/swiper', (req, res) => {
  try {
    res.json({
      code: 200,
      message: '成功',
      data: mockHomeData.swiper
    });
  } catch (error) {
    res.status(500).json({
      code: 500,
      message: '服务器错误',
      data: null
    });
  }
});

// 获取导航图标数据
router.post('/nav', (req, res) => {
  try {
    res.json({
      code: 200,
      message: '成功',
      data: mockHomeData.nav
    });
  } catch (error) {
    res.status(500).json({
      code: 500,
      message: '服务器错误',
      data: null
    });
  }
});

// 获取直播数据
router.post('/live', (req, res) => {
  try {
    res.json({
      code: 200,
      message: '成功',
      data: mockHomeData.live
    });
  } catch (error) {
    res.status(500).json({
      code: 500,
      message: '服务器错误',
      data: null
    });
  }
});

// 获取赚钱数据
router.post('/earn', (req, res) => {
  try {
    res.json({
      code: 200,
      message: '成功',
      data: mockHomeData.earn
    });
  } catch (error) {
    res.status(500).json({
      code: 500,
      message: '服务器错误',
      data: null
    });
  }
});

// 获取快速销售数据
router.post('/sellQuickly', (req, res) => {
  try {
    res.json({
      code: 200,
      message: '成功',
      data: mockHomeData.sellQuickly
    });
  } catch (error) {
    res.status(500).json({
      code: 500,
      message: '服务器错误',
      data: null
    });
  }
});

// 获取活动数据
router.post('/activity', (req, res) => {
  try {
    res.json({
      code: 200,
      message: '成功',
      data: mockHomeData.activity
    });
  } catch (error) {
    res.status(500).json({
      code: 500,
      message: '服务器错误',
      data: null
    });
  }
});

// 获取商品Tab数据
router.post('/goodsTab', (req, res) => {
  try {
    res.json({
      code: 200,
      message: '成功',
      data: mockHomeData.goodsTab
    });
  } catch (error) {
    res.status(500).json({
      code: 500,
      message: '服务器错误',
      data: null
    });
  }
});

// 获取推荐数据
router.post('/recommend', (req, res) => {
  try {
    res.json({
      code: 200,
      message: '成功',
      data: mockHomeData.recommend
    });
  } catch (error) {
    res.status(500).json({
      code: 500,
      message: '服务器错误',
      data: null
    });
  }
});

// 获取直播数据
router.post('/liveData', (req, res) => {
  try {
    res.json({
      code: 200,
      message: '成功',
      data: mockHomeData.liveData
    });
  } catch (error) {
    res.status(500).json({
      code: 500,
      message: '服务器错误',
      data: null
    });
  }
});

// 获取视频数据
router.post('/videoData', (req, res) => {
  try {
    res.json({
      code: 200,
      message: '成功',
      data: mockHomeData.videoData
    });
  } catch (error) {
    res.status(500).json({
      code: 500,
      message: '服务器错误',
      data: null
    });
  }
});

// 获取网格分类数据
router.post('/gridSortData', (req, res) => {
  try {
    res.json({
      code: 200,
      message: '成功',
      data: mockHomeData.gridSortData
    });
  } catch (error) {
    res.status(500).json({
      code: 500,
      message: '服务器错误',
      data: null
    });
  }
});

module.exports = router;